package com.example.warehouse.bus.dao.persist.repository.impl;

import com.example.warehouse.bus.dao.persist.mapper.BusSalesMapper;
import com.example.warehouse.bus.dao.persist.repository.IBusSalesRepository;
import com.example.warehouse.bus.pojo.entity.BusSales;
import com.example.warehouse.bus.pojo.param.BusSalesAddNewParam;
import com.example.warehouse.bus.pojo.param.BusSalesSelectParam;
import com.example.warehouse.bus.pojo.param.BusSalesUpdateParam;
import com.example.warehouse.bus.pojo.vo.BusSalesAndSalesbackSelectCNVO;
import com.example.warehouse.bus.pojo.vo.BusSalesAndSalesbackSelectGNVO;
import com.example.warehouse.bus.pojo.vo.BusSalesSelectVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

/**
 * 销售订单_数据层_实现类
 */
@Slf4j
@Repository
public class BusSalesRepositoryImpl implements IBusSalesRepository {

    @Autowired
    BusSalesMapper busSalesMapper;

    public BusSalesRepositoryImpl() {
        log.info("创建控制器对象: BusSalesRepositoryImpl");
    }

    @Override
    public int instert(BusSalesAddNewParam busSalesAddNewParam, Long idpipo) {
        log.debug("开始执行[添加_销售订单]的数据访问,参数:{},{}", busSalesAddNewParam, idpipo);
        return busSalesMapper.insert(busSalesAddNewParam, idpipo);
    }

    @Override
    public int deleteById(Long id, Long idpipo) {
        log.debug("开始执行[逻辑删除_销售订单]的数据访问,参数:{},{}", id, idpipo);
        return busSalesMapper.deleteById(id, idpipo);
    }

    @Override
    public int update(BusSalesUpdateParam busSalesUpdateParam, Long idpipo) {
        log.debug("开始执行[任意项修改_销售订单]的数据访问,参数{},{}", busSalesUpdateParam, idpipo);
        return busSalesMapper.update(busSalesUpdateParam, idpipo);
    }

    @Override
    public int approvalSales(Long id, Integer approval, Long idpipo) {
        log.debug("开始执行[审批_销售订单]的数据访问,参数{},{},{}", id, approval, idpipo);
        return busSalesMapper.approvalSales(id, approval, idpipo);
    }

    @Override
    public Long count(BusSalesSelectParam busSalesSelectParam, LocalDate begin, LocalDate end) {
        log.debug("开始执行[分页模糊查询_销售订单_结果总数量]的数据访问{},{},{}", busSalesSelectParam, begin, end);
        return busSalesMapper.count(busSalesSelectParam, begin, end);
    }

    @Override
    public List<BusSalesSelectVO> list(BusSalesSelectParam busSalesSelectParam, Integer start, Integer pageSize, LocalDate begin, LocalDate end) {
        log.debug("开始执行[分页模糊查询_销售订单_结果当前页面列表]的数据访问,参数{},{},{},{},{}", busSalesSelectParam, start, pageSize, begin, end);
        return busSalesMapper.list(busSalesSelectParam, start, pageSize, begin, end);
    }

    @Override
    public List<BusSalesAndSalesbackSelectCNVO> listCustomerName() {
        log.debug("开始执行[下拉选查询_客户名称]的数据访问");
        return busSalesMapper.listCustomerName();
    }

    @Override
    public List<BusSalesAndSalesbackSelectGNVO> listGoodsName() {
        log.debug("开始执行[下拉选查询_商品名称]的数据访问");
        return busSalesMapper.listGoodsName();
    }

    @Override
    public List<BusSales> selectAll() {
        List<BusSales> list = busSalesMapper.selectList(null);
        return list;
    }
}
